pkgname=qt5-qtdeclarative
_pkgname=${pkgname/qt5-//}-opensource-src
pkgver=9999
_pkgver=5.9.3
_ver=${_pkgver/_p/-}
_ver=${_ver/_/-}
_ver=${_ver/beta0/beta}
_ver=${_ver/rc0/rc}
_V=${_ver/rc/RC}
pkgrel=0
pkgdesc="Qt5 - QtDeclarative component (#878: armhf is armv7)"
url="http://qt-project.org/"
arch="all"
license="LGPLv2 with exceptions or GPLv3 with exceptions"
makedepends="qt5-qtbase-dev"
subpackages="$pkgname-dev"

case $_pkgver in
*_beta*|*_rc*) _rel=development_releases;;
*) _rel=official_releases;;
esac
source="http://download.qt-project.org/$_rel/qt/${_pkgver%.*}/$_ver/submodules/$_pkgname-$_V.tar.xz"

_qt5_prefix=/usr/lib/qt5
builddir="$srcdir"/$_pkgname-${_V%-*}

prepare() {
	default_prepare
	# Compile for armv7 instead of armhf (armv6), so the JIT compiler
	# works. The non-JIT version is slow and broken (#878).
	if [ "$CARCH" == "armhf" ]; then
		{
			echo 'QMAKE_CLAGS="-mthumb-interwork -mthumb -march=armv7"'
			echo 'QMAKE_CXXFLAGS="-mthumb-interwork -mthumb -march=armv7"'
		} >> "$builddir"/src/qml/qml.pro
		msg "QML will be compiled for armv7 instead of armhf (armv6) (#878)!"
	fi
}

build() {
	cd "$builddir"
	qmake-qt5 && make
}

check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make install INSTALL_ROOT="$pkgdir"

	mkdir -p "$pkgdir"/usr/bin/
	for i in "$pkgdir"/$_qt5_prefix/bin/*; do
		ln -s ../lib/qt5/bin/${i##*/} "$pkgdir"/usr/bin/${i##*/}-qt5
	done
}

sha512sums="933caf5848437cde45b4bbf0c70b6cafbc690657c651508b28138b2f90d2f823f4842bc709f4726e2c88d3913a92240b0dcd9248d83af0d06d7127b9a8211b24  qtdeclarative-opensource-src-5.9.3.tar.xz"
